package cn.zniot.so.apiprovide.business;

import cn.zniot.so.application.constant.Constants;
import cn.zniot.so.application.util.DownloadFile;

import java.util.Map;

public class DownloadFileHandler extends AbstractHandler {
	private Response response = null;
	public String username;
	public String password;
	private String userId;// 文件名称

	/**
	 * 方法名：handle(Map<String, String> params) 
	 * 功　能：根据用户名和密码查询数据库返回id号的xml文件
	 * 参　数：Map<String, String> params - &参数键值对 
	 * 返回值：String - &xml文件包含头文件和实体内容
	 */
	public String handle(Map<String, String> params) {
	    username = params.get("username");
        password = params.get("password");
        userId = params.get("filename");
        DownloadFile.init(Constants.HOME_DIR, userId);
		response = new DownloadFielResponse(userId);
		String xmlStr = pageMaker(response.toJsonPage());
		return xmlStr;
	}

}
